Skip to content

feat: added search bar#2702

Merged
AsCress merged 12 commits into
fossasia:flutterfrom
Yugesh-Kumar-S:Search-bar
Jun 18, 2025
Merged

feat: added search bar#2702
AsCress merged 12 commits into
fossasia:flutterfrom
Yugesh-Kumar-S:Search-bar

Conversation

@Yugesh-Kumar-S

@Yugesh-Kumar-S Yugesh-Kumar-S commented May 24, 2025

Copy link
Copy Markdown
Contributor

Closes #2704
Since the PSLab has many instruments , it becomes hard for users to scroll down to search a specific instrument . So i have added a search bar that filters the instruments based on the instrument name.

Changes

  • Implemented a search bar

Screenshots / Recordings

Final Commit

screen-20250618-222041.mp4
Screen.Recording.2025-05-25.185557.mp4

Checklist:

  • No hard coding: I have used resources from strings.xml, dimens.xml and colors.xml without hard coding any value.
  • No end of file edits: No modifications done at end of resource files strings.xml, dimens.xml or colors.xml.
  • Code reformatting: I have reformatted code and fixed indentation in every file included in this pull request.
  • No extra space: My code does not contain any extra lines or extra spaces than the ones that are necessary.

Summary by Sourcery

Add a search bar to the Instruments screen to allow users to filter the list of instruments by name.

New Features:

  • Add a styled search TextField with clear button at the top of the Instruments screen
  • Implement case-insensitive filtering of the instrument list based on the search query
  • Show an empty-state view with icon and message when no instruments match the search term

@sourcery-ai

sourcery-ai Bot commented May 24, 2025

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Introduces a real-time search feature in InstrumentsScreen by adding state and filtering logic, refactoring the UI to include a search bar with clear/empty-state handling, and updating the list rendering to reflect the filtered results.

Sequence Diagram: Instrument Filtering

sequenceDiagram
    actor User
    participant TextField
    participant ISS as _InstrumentsScreenState

    User->>TextField: Types search query
    TextField->>ISS: onChanged(query)
    ISS->>ISS: _filterInstruments(query)
    ISS->>ISS: setState()
Loading

Sequence Diagram: Clearing Search Input

sequenceDiagram
    actor User
    participant CB as ClearButton
    participant ISS as _InstrumentsScreenState
    participant SC as _searchController

    User->>CB: Taps clear icon
    CB->>ISS: onPressed()
    ISS->>SC: clear()
    ISS->>ISS: _filterInstruments('')
    ISS->>ISS: setState()
Loading

Class Diagram: Changes to _InstrumentsScreenState

classDiagram
    class _InstrumentsScreenState {
        +TextEditingController _searchController
        +List<int> _filteredIndices
        +void initState()
        +void dispose()
        +void _filterInstruments(String query)
        +Widget build(BuildContext context)
        +void _onItemTapped(int index)
    }
Loading

File-Level Changes

Change Details Files
Implemented search filter logic and state management
  • Added TextEditingController (_searchController) and List (_filteredIndices)
  • Created _filterInstruments() to update filteredIndices based on the query
  • Initialized _filteredIndices in initState to show all items by default
  • Disposed _searchController in dispose()
lib/view/instruments_screen.dart
Refactored InstrumentsScreen UI to integrate the search bar
  • Wrapped the list view in a Column to place the TextField above the list
  • Inserted TextField with prefix/suffix icons, themed borders, and clear‐button behavior
  • Conditionally render a ‘no results’ placeholder when filteredIndices is empty
  • Updated ListView.builder to use _filteredIndices for itemCount and lookup
lib/view/instruments_screen.dart

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@CloudyPadmal

Copy link
Copy Markdown
Collaborator

Looks like a good addition. The build is failing for deprecated libraries.

@Yugesh-Kumar-S

Copy link
Copy Markdown
Contributor Author

Looks like a good addition. The build is failing for deprecated libraries.

Replaced deprecated libraries with their latest supported alternatives to fix the build issues.

@github-actions

github-actions Bot commented May 25, 2025

Copy link
Copy Markdown
Contributor

@AsCress AsCress self-requested a review May 26, 2025 02:22
@hpdang hpdang requested a review from CloudyPadmal May 26, 2025 11:27
Comment thread lib/view/instruments_screen.dart Outdated
Comment thread lib/view/instruments_screen.dart Outdated
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(16.0),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a bit too wide. Can you check what is the average padding between a search bar and a similar looking list item in other established Flutter apps?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have checked a few Flutter apps, and it seems that 16px is commonly used for horizontal padding, while vertical padding ranges from 8px to 16px. I will make the changes based on your suggestion sir.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

padding: const EdgeInsets.symmetric(vertical: 8.0,horizontal: 16.0)
image

Comment thread lib/view/instruments_screen.dart Outdated

@CloudyPadmal CloudyPadmal left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a good addition!

@AsCress

AsCress commented May 31, 2025

Copy link
Copy Markdown
Contributor

@Yugesh-Kumar-S Functionality wise this is a nice addition ! However, I feel that we can improve the look of the search bar a bit. I'll get back to you with some suggestions. Would you like to have a look at the design as well ?

@Yugesh-Kumar-S

Copy link
Copy Markdown
Contributor Author

@Yugesh-Kumar-S Functionality wise this is a nice addition ! However, I feel that we can improve the look of the search bar a bit. I'll get back to you with some suggestions. Would you like to have a look at the design as well ?

Yeah sure

@AsCress AsCress added the Status: Review Required Requested reviews from peers and maintainers label Jun 5, 2025
@mariobehling mariobehling requested a review from marcnause June 12, 2025 08:42
@marcnause

Copy link
Copy Markdown
Contributor

My suggestion would be to hide the search bar by default and to either add a 🔍 icon the app bar (between he USB connection symbol and the menu icon) or to add a Floating Action Button to enable the search bar.

Then the user would be able to search, but the search bar would not use a lot of space on smaller screens.

@CloudyPadmal

Copy link
Copy Markdown
Collaborator

Good point @marcnause ! @Yugesh-Kumar-S , Is it possible to add the search bar in to title bar, where a text field expands upon clicking 🔍 button next to the current USB icon button?

@Yugesh-Kumar-S

Copy link
Copy Markdown
Contributor Author

@CloudyPadmal @marcnause I have added the search icon in the Appbar which expands on clicking the icon :) .

screen-20250618-222041.mp4

@CloudyPadmal CloudyPadmal left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I had in mind 👍🏼

@AsCress

AsCress commented Jun 18, 2025

Copy link
Copy Markdown
Contributor

@Yugesh-Kumar-S Makes much more sense now ! Excellent man !

@AsCress AsCress changed the title feat: Added a Search bar feat: added search bar Jun 18, 2025
@AsCress AsCress merged commit 3a64431 into fossasia:flutter Jun 18, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flutter Status: Review Required Requested reviews from peers and maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add search functionality to Instruments Screen

4 participants